﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CommunitySystem.ZhaoLuService;
using org.in2bits.MyXls;

namespace CommunitySystem
{
    public partial class ZhaoLu_LuYongGuanLiControl : UserControl
    {
        private ObservableCollection<ZhaoLuJiHuaModel> poi =
            new ObservableCollection<ZhaoLuJiHuaModel>();
        private ZhaoLuService.ZhaoLuServiceClient Client1 = new ZhaoLuServiceClient();
        public ZhaoLu_LuYongGuanLiControl()
        {
            InitializeComponent();
            Client1.GetZhaoLuJiHuaModelForComCompleted += new EventHandler<GetZhaoLuJiHuaModelForComCompletedEventArgs>(Client1_GetZhaoLuJiHuaModelForComCompleted);
            Client1.GetZhaoLuJiHuaModelForComAsync();
            Client1.GetZhaoLu_LuYongGuanLiCompleted += new EventHandler<GetZhaoLu_LuYongGuanLiCompletedEventArgs>(Client1_GetZhaoLu_LuYongGuanLiCompleted);
            Client1.InsertLuYongLeiXingCompleted += new EventHandler<InsertLuYongLeiXingCompletedEventArgs>(Client1_InsertLuYongLeiXingCompleted);
        }

        void Client1_GetZhaoLu_LuYongGuanLiCompleted(object sender, GetZhaoLu_LuYongGuanLiCompletedEventArgs e)
        {
            for (int i = 0; i < e.Result.Count; i++)
            {
                e.Result[i].Sec = i + 1;
            }
            DGRole.ItemsSource = e.Result;
        }

        void Client1_GetZhaoLuJiHuaModelForComCompleted(object sender, GetZhaoLuJiHuaModelForComCompletedEventArgs e)
        {
            poi = e.Result;
            ObservableCollection<ZhaoLuJiHuaModel> poi1 = new ObservableCollection<ZhaoLuJiHuaModel>();
            poi1.Add(poi.Where(p => p.IsLocked == false).FirstOrDefault());
            nian.ItemsSource = poi1;
            if (poi1.Count > 0) nian.SelectedIndex = 0;
            Load();
        }

        private void Load()
        {
            Client1.GetZhaoLu_LuYongGuanLiAsync(tiaojian);
        }

        private int tiaojian = 0;
        void gangwei_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((ComboBox)sender).SelectedItem != null)
            {
                tiaojian = ((ZhaoLuJiHuaModel)(((ComboBox)sender).SelectedItem)).ID;
            }
        }
        private void ChaData_Click(object sender, RoutedEventArgs e)
        {
            Load();
        }

        private ObservableCollection<ZhaoLu_DaoRuKaoShengModel> selectedempmodel =
            new ObservableCollection<ZhaoLu_DaoRuKaoShengModel>();
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox cb = sender as CheckBox;
            foreach (ZhaoLu_DaoRuKaoShengModel p in DGRole.ItemsSource)
            {
                p.IsSelected = (bool)cb.IsChecked;
                //CheckBox cb1 = DGRole.Columns[0].GetCellContent(p) as CheckBox;
                //cb1.IsChecked = p.IsSelected;
                if (p.IsSelected)
                {
                    if (selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(p);
                    }
                }
                else
                {
                    if (selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault() != null)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(i => i.ID == p.ID).FirstOrDefault());
                    }
                }
            }

        }
        private int count = 0;
        /// <summary>
        /// 确定录用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnIn_Click(object sender, RoutedEventArgs e)
        {
            selectedempmodel.Clear();
            count = 0;
            if (DGRole.ItemsSource != null)
            {
                foreach (
                    ZhaoLu_DaoRuKaoShengModel i in
                        (ObservableCollection<ZhaoLu_DaoRuKaoShengModel>)DGRole.ItemsSource)
                {

                    if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(i);
                    }
                    if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                    }
                }
                foreach (
                    ZhaoLu_DaoRuKaoShengModel i in selectedempmodel)
                {
                    if (i.TiJianBeiZhu == "暂缓")
                    {
                        SilverlightMessageBoxLibrary.Message.ErrorMessage("体检结果为暂缓，只能暂缓录用！");
                        return;
                    }
                    if (i.LuYongLeiXing == "确定录用")
                    {
                        SilverlightMessageBoxLibrary.Message.ErrorMessage("所选人员有已录用人员，请重新选择！");
                        return;
                    }
                }
                
            }
            if (selectedempmodel.Count <= 0)
            {
                SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择要确定录用的人员！");
                return;
            }
            if (MessageBox.Show("确定要确定录用吗？", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                ZhaoLu_LuYongGuanLiWindow RMWindow = new ZhaoLu_LuYongGuanLiWindow();
                RMWindow.Closed += new EventHandler(RMWindow_Closed);
                RMWindow.Show();
                
            }
        }
        void RMWindow_Closed(object sender, EventArgs e)
        {
            //if (((ZhaoLu_LuYongGuanLiWindow)sender).Dt == null || Convert.ToDateTime(((ZhaoLu_LuYongGuanLiWindow)sender).Dt) == Convert.ToDateTime("1900-01-01"))
            //{
            //    SilverlightMessageBoxLibrary.Message.ErrorMessage("请选择录用日期！");
            //    return;
            //}
            if(((ZhaoLu_LuYongGuanLiWindow)sender).Dt!=null)
            Client1.InsertLuYongLeiXingAsync(selectedempmodel, "确定录用", ((ZhaoLu_LuYongGuanLiWindow)sender).Dt);
        }
        void Client1_InsertLuYongLeiXingCompleted(object sender, InsertLuYongLeiXingCompletedEventArgs e)
        {
            SilverlightMessageBoxLibrary.Message.InfoMessage("录用成功!");
            Load();
        }
        /// <summary>
        /// 暂缓录用
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditData_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("确定要暂缓录用吗？", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
            {
                selectedempmodel.Clear();
                count = 0;
                if (DGRole.ItemsSource != null)
                {
                    foreach (
                        ZhaoLu_DaoRuKaoShengModel i in
                            (ObservableCollection<ZhaoLu_DaoRuKaoShengModel>) DGRole.ItemsSource)
                    {
                        if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                        {
                            selectedempmodel.Add(i);
                        }
                        if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                        {
                            selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                        }
                    }
                }
                if (selectedempmodel.Count > 0)
                {
                    Client1.InsertLuYongLeiXingAsync(selectedempmodel, "暂缓录用", ((ZhaoLu_LuYongGuanLiWindow)sender).Dt);
                }
            }
        }
        private Stream ss = null;
        /// <summary>
        /// 导出  XlsDocument
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOut_Click(object sender, RoutedEventArgs e)
        {
            selectedempmodel.Clear();
            if (DGRole.ItemsSource != null)
            {
                foreach (
                    ZhaoLu_DaoRuKaoShengModel i in
                        (ObservableCollection<ZhaoLu_DaoRuKaoShengModel>) DGRole.ItemsSource)
                {
                    if (i.IsSelected == true && selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() == null)
                    {
                        selectedempmodel.Add(i);
                    }
                    if (selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault() != null && i.IsSelected == false)
                    {
                        selectedempmodel.Remove(selectedempmodel.Where(p => p.ID == i.ID).FirstOrDefault());
                    }
                }
                if (selectedempmodel != null && selectedempmodel.Count > 0)
                {
                    var downLoad = new SaveFileDialog()
                                       {
                                           //Filter = "Excel files(2007~2010) (*.xlsx)|*.xlsx|Excel files(2003) (*.xls)|*.xls", //"Excel files (*.xlsx)|*.xlsx|(*.xls)|*.xls",
                                           Filter = "Excel files(2003) (*.xls)|*.xls",
                                       };
                    if (downLoad.ShowDialog() == true)
                    {
                        ss = downLoad.OpenFile();
                        PageInit();
                    }
                }
                else SilverlightMessageBoxLibrary.Message.ErrorMessage("没有要导出的数据！");
            }

        }

        public void PageInit()
        {
            XlsDocument xls = new XlsDocument();
            XF xf = xls.NewXF();
            xf.HorizontalAlignment = HorizontalAlignments.Centered;
            xf.VerticalAlignment = VerticalAlignments.Centered;
            xf.UseBorder = true;
            xf.TopLineStyle = 1;
            xf.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf.BottomLineStyle = 1;
            xf.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf.LeftLineStyle = 1;
            xf.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf.RightLineStyle = 1;
            xf.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf.TextWrapRight = true;

            XF xf1 = xls.NewXF();
            xf1.UseBorder = true;
            xf1.TopLineStyle = 1;
            xf1.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.BottomLineStyle = 1;
            xf1.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.LeftLineStyle = 1;
            xf1.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.RightLineStyle = 1;
            xf1.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf1.HorizontalAlignment = HorizontalAlignments.Centered;
            xf1.VerticalAlignment = VerticalAlignments.Centered;
            xf1.Font.Bold = true;
            xf1.Font.Height = 15 * 20;

            XF xf3 = xls.NewXF();
            xf3.UseBorder = true;
            xf3.TopLineStyle = 1;
            xf3.TopLineColor = org.in2bits.MyXls.Colors.Black;
            xf3.BottomLineStyle = 1;
            xf3.BottomLineColor = org.in2bits.MyXls.Colors.Black;
            xf3.LeftLineStyle = 1;
            xf3.LeftLineColor = org.in2bits.MyXls.Colors.Black;
            xf3.RightLineStyle = 1;
            xf3.RightLineColor = org.in2bits.MyXls.Colors.Black;
            xf3.HorizontalAlignment = HorizontalAlignments.Centered;
            xf3.VerticalAlignment = VerticalAlignments.Centered;
            xf3.Font.Bold = true;
            xf3.Font.Height = 12 * 20;

            Worksheet sheet1 = xls.Workbook.Worksheets.AddNamed("人员录用名单");
            sheet1.Cells.Merge(1, 1, 1, 52);
            sheet1.Cells.Add(1, 1, "徐汇区" + (DateTime.Today.Year - nian.SelectedIndex).ToString() + "年招录人员录用名单", xf1);
            sheet1.Cells.Add(2, 1, "序号", xf3);
            sheet1.Cells.Add(2, 2, "注册编号", xf3);
            sheet1.Cells.Add(2, 3, "姓名", xf3);
            sheet1.Cells.Add(2, 4, "身份证号", xf3);
            sheet1.Cells.Add(2, 5, "职位ID", xf3);
            sheet1.Cells.Add(2, 6, "招录单位", xf3);
            sheet1.Cells.Add(2, 7, "用人部门", xf3);
            sheet1.Cells.Add(2, 8, "报考职位", xf3);
            sheet1.Cells.Add(2, 9, "招考科目", xf3);
            sheet1.Cells.Add(2, 10, "申论", xf3);

            sheet1.Cells.Add(2, 11, "行测", xf3);
            sheet1.Cells.Add(2, 12, "政法", xf3);
            sheet1.Cells.Add(2, 13, "总分", xf3);
            sheet1.Cells.Add(2, 14, "性别", xf3);
            sheet1.Cells.Add(2, 15, "出生日期", xf3);
            sheet1.Cells.Add(2, 16, "健康程度", xf3);
            sheet1.Cells.Add(2, 17, "身高", xf3);
            sheet1.Cells.Add(2, 18, "体重", xf3);
            sheet1.Cells.Add(2, 19, "民族", xf3);
            sheet1.Cells.Add(2, 20, "婚姻状况", xf3);

            sheet1.Cells.Add(2, 21, "配偶学历", xf3);
            //sheet1.Cells.Add(2, 22, "注册编号", xf3);
            sheet1.Cells.Add(2, 22, "考生身份", xf3);
            sheet1.Cells.Add(2, 23, "学历", xf3);
            sheet1.Cells.Add(2, 24, "政治面貌", xf3);
            sheet1.Cells.Add(2, 25, "学位", xf3);
            sheet1.Cells.Add(2, 26, "本科毕业院校", xf3);
            sheet1.Cells.Add(2, 27, "本科专业", xf3);
            sheet1.Cells.Add(2, 28, "本科毕业时间", xf3);
            sheet1.Cells.Add(2, 29, "硕士毕业院校", xf3);

            sheet1.Cells.Add(2, 30, "硕士专业", xf3);
            sheet1.Cells.Add(2, 31, "硕士毕业时间", xf3);
            sheet1.Cells.Add(2, 32, "博士毕业院校", xf3);
            sheet1.Cells.Add(2, 33, "博士专业", xf3);
            sheet1.Cells.Add(2, 34, "博士毕业时间", xf3);
            sheet1.Cells.Add(2, 35, "个人简历", xf3);
            sheet1.Cells.Add(2, 36, "特长获职业证书", xf3);
            sheet1.Cells.Add(2, 37, "所学主要课程", xf3);
            sheet1.Cells.Add(2, 38, "外语1", xf3);
            sheet1.Cells.Add(2, 39, "外语2", xf3);

            sheet1.Cells.Add(2, 40, "外语等级1", xf3);
            sheet1.Cells.Add(2, 41, "外语等级2", xf3);
            sheet1.Cells.Add(2, 42, "计算机水平", xf3);
            sheet1.Cells.Add(2, 43, "通讯地址", xf3);
            sheet1.Cells.Add(2, 44, "联系方式", xf3);
            sheet1.Cells.Add(2, 45, "手机号码", xf3);
            sheet1.Cells.Add(2, 46, "工作单位", xf3);
            sheet1.Cells.Add(2, 47, "工作年限", xf3);
            sheet1.Cells.Add(2, 48, "毕业生界别", xf3);
            sheet1.Cells.Add(2, 49, "生源", xf3);

            sheet1.Cells.Add(2, 50, "户籍", xf3);
            sheet1.Cells.Add(2, 51, "邮编", xf3);

            ColumnInfo colInfoxueli1 = new ColumnInfo(xls, sheet1);
            colInfoxueli1.Width = 40 * 256;
            colInfoxueli1.ColumnIndexStart = 6;
            colInfoxueli1.ColumnIndexEnd = 6;
            sheet1.AddColumnInfo(colInfoxueli1);

            ColumnInfo colInfoxueli2 = new ColumnInfo(xls, sheet1);
            colInfoxueli2.Width = 15 * 256;
            colInfoxueli2.ColumnIndexStart = 26;
            colInfoxueli2.ColumnIndexEnd = 26;
            sheet1.AddColumnInfo(colInfoxueli2);

            ColumnInfo colInfoxueli3 = new ColumnInfo(xls, sheet1);
            colInfoxueli3.Width = 15 * 256;
            colInfoxueli3.ColumnIndexStart = 29;
            colInfoxueli3.ColumnIndexEnd = 29;
            sheet1.AddColumnInfo(colInfoxueli3);

            ColumnInfo colInfoxueli4 = new ColumnInfo(xls, sheet1);
            colInfoxueli4.Width = 15 * 256;
            colInfoxueli4.ColumnIndexStart = 32;
            colInfoxueli4.ColumnIndexEnd = 32;
            sheet1.AddColumnInfo(colInfoxueli4);

            ColumnInfo colInfoxueli5 = new ColumnInfo(xls, sheet1);
            colInfoxueli5.Width = 30 * 256;
            colInfoxueli5.ColumnIndexStart = 35;
            colInfoxueli5.ColumnIndexEnd = 35;
            sheet1.AddColumnInfo(colInfoxueli5);
            ColumnInfo colInfoxueli6 = new ColumnInfo(xls, sheet1);
            colInfoxueli6.Width = 30 * 256;
            colInfoxueli6.ColumnIndexStart = 36;
            colInfoxueli6.ColumnIndexEnd = 36;
            sheet1.AddColumnInfo(colInfoxueli6);

            ColumnInfo colInfoxueli7 = new ColumnInfo(xls, sheet1);
            colInfoxueli7.Width = 30 * 256;
            colInfoxueli7.ColumnIndexStart = 37;
            colInfoxueli7.ColumnIndexEnd = 37;
            sheet1.AddColumnInfo(colInfoxueli7);

            ColumnInfo colInfoxueli8 = new ColumnInfo(xls, sheet1);
            colInfoxueli8.Width = 25 * 256;
            colInfoxueli8.ColumnIndexStart = 43;
            colInfoxueli8.ColumnIndexEnd = 43;
            sheet1.AddColumnInfo(colInfoxueli8);


            for (int i = 0; i < selectedempmodel.Count; i++)
            {
                sheet1.Cells.Add(i + 3, 1, i + 1, xf);
                if (selectedempmodel[i].ZCBH != null) sheet1.Cells.Add(i + 3, 2, selectedempmodel[i].ZCBH.ToString(), xf);
                if (selectedempmodel[i].XingMing != null) sheet1.Cells.Add(i + 3, 3, selectedempmodel[i].XingMing.ToString(), xf);
                if (selectedempmodel[i].SFZH != null) sheet1.Cells.Add(i + 3, 4, selectedempmodel[i].SFZH.ToString(), xf);
                if (selectedempmodel[i].ZWID != null) sheet1.Cells.Add(i + 3, 5, selectedempmodel[i].ZWID.ToString(), xf);
                if (selectedempmodel[i].ZLDW != null) sheet1.Cells.Add(i + 3, 6, selectedempmodel[i].ZLDW.ToString(), xf);
                if (selectedempmodel[i].YRBM != null) sheet1.Cells.Add(i + 3, 7, selectedempmodel[i].YRBM.ToString(), xf);
                if (selectedempmodel[i].BBZW != null) sheet1.Cells.Add(i + 3, 8, selectedempmodel[i].BBZW.ToString(), xf);
                if (selectedempmodel[i].ZKKM != null) sheet1.Cells.Add(i + 3, 9, selectedempmodel[i].ZKKM.ToString(), xf);
                if (selectedempmodel[i].SL != null) sheet1.Cells.Add(i + 3, 10, selectedempmodel[i].SL.ToString(), xf);

                if (selectedempmodel[i].XC != null) sheet1.Cells.Add(i + 3, 11, selectedempmodel[i].XC.ToString(), xf);
                if (selectedempmodel[i].ZF != null) sheet1.Cells.Add(i + 3, 12, selectedempmodel[i].ZF.ToString(), xf);
                if (selectedempmodel[i].ZongFen != null) sheet1.Cells.Add(i + 3, 13, selectedempmodel[i].ZongFen.ToString(), xf);
                if (selectedempmodel[i].XB != null) sheet1.Cells.Add(i + 3, 14, selectedempmodel[i].XB.ToString(), xf);
                if (selectedempmodel[i].CSRQ != null) sheet1.Cells.Add(i + 3, 15, selectedempmodel[i].CSRQ.ToString(), xf);
                if (selectedempmodel[i].JKCD != null) sheet1.Cells.Add(i + 3, 16, selectedempmodel[i].JKCD.ToString(), xf);
                if (selectedempmodel[i].SG != null) sheet1.Cells.Add(i + 3, 17, selectedempmodel[i].SG.ToString(), xf);
                if (selectedempmodel[i].TZ != null) sheet1.Cells.Add(i + 3, 18, selectedempmodel[i].TZ.ToString(), xf);
                if (selectedempmodel[i].MZ != null) sheet1.Cells.Add(i + 3, 19, selectedempmodel[i].MZ.ToString(), xf);
                if (selectedempmodel[i].HYZK != null) sheet1.Cells.Add(i + 3, 20, selectedempmodel[i].HYZK.ToString(), xf);

                if (selectedempmodel[i].POXL != null) sheet1.Cells.Add(i + 3, 21, selectedempmodel[i].POXL.ToString(), xf);
                if (selectedempmodel[i].KSSF != null) sheet1.Cells.Add(i + 3, 22, selectedempmodel[i].KSSF.ToString(), xf);
                if (selectedempmodel[i].XL != null) sheet1.Cells.Add(i + 3, 23, selectedempmodel[i].XL.ToString(), xf);
                if (selectedempmodel[i].ZZMM != null) sheet1.Cells.Add(i + 3, 24, selectedempmodel[i].ZZMM.ToString(), xf);
                if (selectedempmodel[i].XW != null) sheet1.Cells.Add(i + 3, 25, selectedempmodel[i].XW.ToString(), xf);
                if (selectedempmodel[i].BKBYYX != null) sheet1.Cells.Add(i + 3, 26, selectedempmodel[i].BKBYYX.ToString(), xf);
                if (selectedempmodel[i].BKZY != null) sheet1.Cells.Add(i + 3, 27, selectedempmodel[i].BKZY.ToString(), xf);
                if (selectedempmodel[i].BKBYSJ != null) sheet1.Cells.Add(i + 3, 28, selectedempmodel[i].BKBYSJ.ToString(), xf);
                if (selectedempmodel[i].SSYX != null) sheet1.Cells.Add(i + 3, 29, selectedempmodel[i].SSYX.ToString(), xf);
                if (selectedempmodel[i].SSZY != null) sheet1.Cells.Add(i + 3, 30, selectedempmodel[i].SSZY.ToString(), xf);

                if (selectedempmodel[i].SSBYSJ != null) sheet1.Cells.Add(i + 3, 31, selectedempmodel[i].SSBYSJ.ToString(), xf);
                if (selectedempmodel[i].BSYX != null) sheet1.Cells.Add(i + 3, 32, selectedempmodel[i].BSYX.ToString(), xf);
                if (selectedempmodel[i].BSZY != null) sheet1.Cells.Add(i + 3, 33, selectedempmodel[i].BSZY.ToString(), xf);
                if (selectedempmodel[i].BSBYSJ != null) sheet1.Cells.Add(i + 3, 34, selectedempmodel[i].BSBYSJ.ToString(), xf);
                if (selectedempmodel[i].GRJL != null) sheet1.Cells.Add(i + 3, 35, selectedempmodel[i].GRJL.ToString(), xf);
                if (selectedempmodel[i].TC != null) sheet1.Cells.Add(i + 3, 36, selectedempmodel[i].TC.ToString(), xf);
                if (selectedempmodel[i].SXZYKC != null) sheet1.Cells.Add(i + 3, 37, selectedempmodel[i].SXZYKC.ToString(), xf);
                if (selectedempmodel[i].WY1 != null) sheet1.Cells.Add(i + 3, 38, selectedempmodel[i].WY1.ToString(), xf);
                if (selectedempmodel[i].WY2 != null) sheet1.Cells.Add(i + 3, 39, selectedempmodel[i].WY2.ToString(), xf);
                if (selectedempmodel[i].WYDJ1 != null) sheet1.Cells.Add(i + 3, 40, selectedempmodel[i].WYDJ1.ToString(), xf);

                if (selectedempmodel[i].WYDJ2 != null) sheet1.Cells.Add(i + 3, 41, selectedempmodel[i].WYDJ2.ToString(), xf);
                if (selectedempmodel[i].JSJSP != null) sheet1.Cells.Add(i + 3, 42, selectedempmodel[i].JSJSP.ToString(), xf);
                if (selectedempmodel[i].TXDZ != null) sheet1.Cells.Add(i + 3, 43, selectedempmodel[i].TXDZ.ToString(), xf);
                if (selectedempmodel[i].LXFS != null) sheet1.Cells.Add(i + 3, 44, selectedempmodel[i].LXFS.ToString(), xf);
                if (selectedempmodel[i].SJHM != null) sheet1.Cells.Add(i + 3, 45, selectedempmodel[i].SJHM.ToString(), xf);
                if (selectedempmodel[i].GZDW != null) sheet1.Cells.Add(i + 3, 46, selectedempmodel[i].GZDW.ToString(), xf);
                if (selectedempmodel[i].GZNX != null) sheet1.Cells.Add(i + 3, 47, selectedempmodel[i].GZNX.ToString(), xf);
                if (selectedempmodel[i].BYSJB != null) sheet1.Cells.Add(i + 3, 48, selectedempmodel[i].BYSJB.ToString(), xf);
                if (selectedempmodel[i].SY != null) sheet1.Cells.Add(i + 3, 49, selectedempmodel[i].SY.ToString(), xf);
                if (selectedempmodel[i].HJ != null) sheet1.Cells.Add(i + 3, 50, selectedempmodel[i].HJ.ToString(), xf);

                if (selectedempmodel[i].YB != null) sheet1.Cells.Add(i + 3, 51, selectedempmodel[i].YB.ToString(), xf);
            }
            xls.Save(ss);
            ss.Close();
            ss.Dispose();
            SilverlightMessageBoxLibrary.Message.InfoMessage("导出成功！");

        }
        private string islock = "0";
        private void chkHiddenCols_Unchecked(object sender, RoutedEventArgs e)
        {
            islock = "0";
            ObservableCollection<ZhaoLuJiHuaModel> poi1 = new ObservableCollection<ZhaoLuJiHuaModel>();
            poi1.Add(poi.Where(p => p.IsLocked == false).FirstOrDefault());
            nian.ItemsSource = poi1;
            if (poi1.Count > 0) nian.SelectedIndex = 0;
            Load();
        }
        private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            islock = "1";
            ObservableCollection<ZhaoLuJiHuaModel> poi1 = new ObservableCollection<ZhaoLuJiHuaModel>();
            foreach (ZhaoLuJiHuaModel i in poi)
            {
                if (i.IsLocked) poi1.Add(i);
            }
            nian.ItemsSource = poi1;
            if (poi1.Count > 0) nian.SelectedIndex = 0;
            Load();
        }
    }
}
